package nc;

import java.lang.reflect.Method;

import org.junit.Test;

import test.Father;

public class Beike {

    public int mota(int[] nums1, int[] add1, int[] nums2, int[] add2) {
        int n = nums1.length;
        int i = 0, j = 0;
        //int ti = 0, tj = 0;
        int cur = 0, need = 0;
        while (i < n && j < n) {
            int n1 = add1[i] - nums1[i];
            int n2 = add2[j] - nums2[j];
            cur = Math.max(n1, n2) + cur;
            if (n1 >= n2) {
                i++;
            } else {
                j++;
            }
            if (cur < 0) {
                need -= cur;
            }
        }
        while (i < n) {
            int n1 = add1[i] - nums1[i];
            cur += n1;
            if (cur < 0) {
                need -= cur;
            }
        }
        while (j < n) {
            int n2 = add2[j] - nums2[j];
            cur += n2;
            if (cur < 0) {
                need -= cur;
            }
        }
        return need;
    }

    @Test
    public void test() {
        int[] nums1 = new int[]{};
        int[] add1 = new int[]{};
        int[] nums2 = new int[]{};
        int[] add2 = new int[]{};
        
    }


    

    class Sun extends Father {
        public void method2() {

        }
    }

    @Test
    public void test2() throws NoSuchMethodException, SecurityException {
        Sun sun = new Sun();
        Class<?> clazz = Sun.class;
        // Method m = clazz.getMethod("method", null);
        for (Method m : clazz.getMethods()) {
            System.out.println(m.getName());
        }
    }
    
}
